package com.shuangti.seatausermanagement.controller;



import com.shuangti.seatausermanagement.entity.User;
import com.shuangti.seatausermanagement.service.impl.UserManagementServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


@RequestMapping("/api/usermanage")
@RestController
public class UserController {

    @Autowired
    UserManagementServiceImpl userManagementService;

    @PostMapping("/addUser")
    public Map<String,String> addUser(User user){
        userManagementService.addUser(user);

        Map<String, String> result = new HashMap<>();
        result.put("200","添加成功");
        return  result;
    }

    @PostMapping("/delUser")
    public Map<String,String> delUser(Long user_id){
        userManagementService.deleteUser(user_id);

        Map<String, String> result = new HashMap<>();
        result.put("200","删除成功");
        return  result;
    }

    @PostMapping("/updateUserInfo")
    public Map<String,String> updateUserInfo(User user){
        Map<String, String> result = new HashMap<>();
        if(userManagementService.updateUserInfo(user)){
            result.put("200","修改成功");
        }
        else {
            result.put("400","修改失败");
        }
        return  result;
    }
}
